import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';

function render() {
  const app = createApp(App);
  app.use(router);
  app.use(ElementPlus);
  app.mount('#sub-app');
}

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render();
}

renderWithQiankun({
  mount() {
    render();
  },
  bootstrap() {},
  unmount() {
    document.getElementById('sub-app')!.innerHTML = '';
  }
});